package com.yzf.enterprise.project.controller;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yzf.enterprise.common.constant.Constants;
import com.yzf.enterprise.framework.security.service.SysLoginService;
import com.yzf.enterprise.framework.web.domain.AjaxResult;
import com.yzf.enterprise.project.domain.LoginDTO;
import com.yzf.enterprise.project.service.ISysUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yunzhangfang
 * @since 2020-08-04
 */
@RestController
public class SysUserController {

    @Autowired
    private SysLoginService loginService;

    /**
     * 用户登录
     *
     * @return 结果
     */
    @ApiOperation("用户登录")
    @PostMapping("/login")
    public AjaxResult login(@RequestBody LoginDTO loginDTO) {
        AjaxResult ajax = AjaxResult.success();
        // 生成令牌
        String token = loginService.login(loginDTO.getUserName(), loginDTO.getPassword());
        ajax.setResult(token);
        return ajax;
    }

}
